import Vue from 'vue'
import App from './App'
import router from './router'
import Axios from "axios"
import qs from "qs"
import store from "./store"
Axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
Axios.interceptors.request.use(
  config => {
    if(config.method=='post'){
      config.data=qs.stringify(config.data)
    }
    // if (token) {  // 每次发送请求之前判断是否存在token，如果存在，则统一在http请求的header都加上token，不用每次请求都手动添加了
    //   //config.headers.Authorization = token;
    // }
    return config;
  },
  err => {
    return Promise.reject(err);
  });

Vue.prototype.$axios = Axios
Vue.config.productionTip = false
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
